<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<jsp:include page="base.jsp"></jsp:include>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>数据处理平台 | 登录</title>
<!-- Tell the browser to be responsive to screen width -->
<meta
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
	name="viewport">
<!-- Bootstrap 3.3.6 -->
<link rel="stylesheet" href="${url }bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="bootstrap/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="bootstrap/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="${url }dist/css/AdminLTE.min.css">
<!-- iCheck -->
<link rel="stylesheet" href="${url }plugins/iCheck/square/blue.css">

<!--[if lt IE 9]>
  <script src="//cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
<style type="text/css">
.callout-danger {
	width: 30%;
	margin-left: 35%;
}
</style>
</head>
<body class="hold-transition login-page">
	<div class="callout callout-danger" style="display: none;">
		<h4>提示!</h4>
		<p>用户名或密码错误！</p>
	</div>
	<div class="login-box">
		<div class="login-logo">
			<a href="javascript:;"><b>数据处理平台</b>VRV</a>
		</div>
		<!-- /.login-logo -->
		<div class="login-box-body">
			<p class="login-box-msg"></p>
			<form id="loginForm" action="login" method="post">
				<div class="form-group has-feedback">
					<input type="text" class="form-control" name="userName"
						id="userName" placeholder="UserName"> <span
						class="glyphicon glyphicon-envelope form-control-feedback"></span>
				</div>
				<div class="form-group has-feedback">
					<input type="password" class="form-control" name="password"
						id="password" placeholder="Password"> <span
						class="glyphicon glyphicon-lock form-control-feedback"></span>
				</div>
				<div class="row">
					<div class="col-xs-8">
						<div class="checkbox icheck">
							<label> 用户类型：<select id="userType">
									<option value="1">管理员</option>
									<option value="0">普通用户</option>
									<option value="2">分析用户</option>
							</select>
							</label>
						</div>
					</div>
					<!-- /.col -->
					<div class="col-xs-4">
						<a href="javascript:;" id="login"
							class="btn btn-primary btn-block btn-flat">登录</a>
					</div>
					<!-- /.col -->
				</div>
			</form>
		</div>
		<!-- /.login-box-body -->
	</div>
	<!-- /.login-box -->

	<!-- jQuery 2.2.3 -->
	<script src="${url }plugins/jQuery/jquery-2.2.3.min.js"></script>
	<!-- Bootstrap 3.3.6 -->
	<script src="${url }bootstrap/js/bootstrap.min.js"></script>
	<!-- iCheck -->
	<script src="${url }plugins/iCheck/icheck.min.js"></script>
	<script>
		$(function() {
			$('input').iCheck({
				checkboxClass : 'icheckbox_square-blue',
				radioClass : 'iradio_square-blue',
				increaseArea : '20%' // optional
			});

			$('#login').on("click", function() {
				var password = $('#password').val();
				var userName = $('#userName').val();
				var tableName = "";
				if ($("#userType").val() == 0) {
					tableName = "userinfo";
				} else {
					tableName = "admininfo";
				}
				$.ajax({
					cache : false, //false表示不会从浏览器的缓存信息中加载数据

					async : false, //异步同步     true为同步
					type : "POST", //请求方式

					url : path + 'loginByHttpClient', //发送请求地址
					data : {
						account : userName,
						password : password,
						tableName : tableName,
						type : $("#userType").val()
					},
					success : function(result) {
						if (result != 'false') {
							location.href = path + "main/index";
						} else {
							$('.callout-danger').show().hide(4000);
						}
					}
				});
			});
		});
	</script>
</body>
</html>
